package com.example.ntier.model.bll;

import com.example.ntier.model.entity.Employee;

public class EmployeeValidator implements Validator<Integer, Employee> {

	private DeparmentValidator deparmentValidator;

	public EmployeeValidator() {
		this.deparmentValidator = new DeparmentValidator();
	}

	@Override
	public boolean validateEntity(Employee entity) {
		boolean result = true;
		if (entity.getFirstName().isEmpty() || entity.getFirstName().trim().length() < 3) result = false;
		if (entity.getLastName().isEmpty() || entity.getLastName().trim().length() < 2) result = false;
		if (entity.getDepartment() == null) result = false;
		if (entity.getDepartment() != null) {
			result = deparmentValidator.validateEntity(entity.getDepartment());
		}
		return result;
	}

}
